package com.ddxz.flink.chars;

import com.ddxz.flink.chars.map.DdxzSplitterMap;
import org.apache.flink.api.java.DataSet;
import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.flink.api.java.operators.DataSource;
import org.apache.flink.api.java.tuple.Tuple2;

/**
 * class description
 *
 * @author 朱宗刚
 * @version 1.0.0
 * @date 2020/9/1
 */

public class CharApplication {
    public static void main(String[] args) throws Exception {
        ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
        DataSource<String> ds = env.readTextFile("D:\\move\\apache-maven-3.6.3\\conf\\settings.xml");
        DataSet<Tuple2<String, Integer>> dataSet = ds.flatMap(new DdxzSplitterMap()).groupBy(0).sum(1);
        dataSet.print(); // 对DataSet，print会自动调用execute，与流处理方式不同
//        env.execute();
    }
}
